home *** CD-ROM | disk | FTP | other *** search
/ HyperLib 1997 Winter - Disc 1 / HYPERLIB-1997-Winter-CD1.ISO.7z / HYPERLIB-1997-Winter-CD1.ISO / オンラインウェア / PRG / ICProgKit 1.3.sit / ICProgKit1.3 / Goodies / ICReadOnly / ICSpecificOverride.p next >
Text File  |  1995-05-01  |  6KB  |  164 lines

  1. unit ICSpecificOverride;
  2.  
  3. (* Internet Config Specific Overide Component *)
  4.  
  5. (* Routine names have an ICSO prefix for Internet Config Specific Override. *)
  6.  
  7. (* To create an IC override component you need to make a copy of this *)
  8. (* file and fill in the blanks. This is an N stage process: *)
  9.  
  10. (*  1. Make a copy of this file. *)
  11. (*  2. Change kOurComponentManufacturer to your manufacturer code. *)
  12. (*  3. Add any shared globals to the sharedGlobals record. *)
  13. (*  4. If you have shared globals then init them in ICSOInitShared. *)
  14. (*  5. If the shared globals need cleaning up then clean them ICSOCleanShared. *)
  15. (*  6. Add any instance specific globals to globalsRecord. *)
  16. (*  7. If you have globals then init them in ICSOInitGlobals. *)
  17. (*  8. If the globals need cleaning up then clean them ICSOCleanGlobals. *)
  18. (*  9. If you want to add a completely new routine or remove support *)
  19. (*     for one of the built in routines then modify ICSOCanDo accordingly. *)
  20. (* 10. Modify ICSOWhatToOverride to return the correct ProcPtr for each *)
  21. (*     routine that you override or add. *)
  22. (* 11. Write each routine. If you want the component to continue calling *)
  23. (*     through to the captured component for this routine then have your *)
  24. (*     routine return delegateThisCallErr. *)
  25. (* 12. Smirk at the wonders of Component Manager. *)
  26. (* 13. Looking inside ICGenericOverride and frown at the wonders of Component Manager. *)
  27.  
  28. (* Share and Enjoy. *)
  29.  
  30. (* Quinn *)
  31. (* 12 Feb 1995 *)
  32.  
  33. interface
  34.  
  35.     uses
  36.         Components;
  37.  
  38.     const
  39.         kOurComponentManufacturer = 'ICRo';
  40. (* You must set this up appropriately. Things will not be good otherwise. *)
  41.  
  42.         delegateThisCallErr = $81234568;
  43. (* Return this from a component routine if you want the generic override *)
  44. (* component to pass this call through to the captured component. *)
  45.  
  46.     type
  47.         sharedGlobals = record
  48.                 delegate: Component;
  49.                 (* add your own shared globals here *)
  50.             end;
  51.         sharedGlobalsPtr = ^sharedGlobals;
  52.  
  53.         globalsRecord = record
  54.                 self: ComponentInstance;
  55.                 target: ComponentInstance;
  56.                 delegate: ComponentInstance;
  57.                 shared: sharedGlobalsPtr;
  58.                 (* add your own component specific globals here*)
  59.             end;
  60.         globalsPtr = ^globalsRecord;
  61.         globalsHandle = ^globalsPtr;
  62.  
  63. (* Except when otherwise noted the globals handle is *)
  64. (* locked when any of these routines are called. *)
  65.  
  66.     function ICSOInitShared (globals: globalsHandle): ComponentResult;
  67. (* This routine is called to init the shared globals. *)
  68. (* If you return an error then you should make sure your part of *)
  69. (* the shared globals are 'clean'. *)
  70.  
  71.     function ICSOCleanShared (globals: globalsHandle): ComponentResult;
  72. (* This routine is called to clean the shared globals. *)
  73. (* WARNING:  This will never been called if you're using an old version *)
  74. (* of the Component Manager. Workaround: If your specifics only bleeds *)
  75. (* small amounts of memory then don't worry. If your specifics bleeds a *)
  76. (* lot of memory or other resources (such as open files) then refuse to *)
  77. (* install with older Component Managers (I think it was fixed in v2 of the *)
  78. (* manager. *)
  79.  
  80.     function ICSOInitGlobals (globals: globalsHandle): ComponentResult;
  81. (* This routine inits the override specific fields of the component *)
  82. (* specific globals. If it returns an error then the globals must be 'clean'. *)
  83.  
  84.     function ICSOCleanGlobals (globals: globalsHandle): ComponentResult;
  85. (* This routine cleans up the component specific globals, disposing any *)
  86. (* pointers and otherwise releasing any allocated resources. *)
  87.  
  88.     function ICSOCanDo (globals: globalsHandle; selector: integer): ComponentResult;
  89. (* This routine is called in response to a component can do request. *)
  90. (* You should set component result to: *)
  91. (*   -1 if you definitely want to say that the component can't do this *)
  92. (*     0 if you definitely want to say that the component can do this *)
  93. (*     1 if you want to let the target decide *)
  94. (* WARNING: These constants are quite different from the constants *)
  95. (* used by a standard Component Manager CanDo request. *)
  96.  
  97.     function ICSOWhatToOverride (globals: globalsHandle; selector: integer): ProcPtr;
  98. (* Return nil if you do not want to override this what. *)
  99. (* Return a pointer to a procedure with the appropriate signature *)
  100. (* if you do. *)
  101. (* WARNING: globals will not necessarily be locked and may be nil!!! *)
  102.  
  103. implementation
  104.  
  105.     uses
  106.         ICTypes, ICCAPI, ICComponentSelectors;
  107.  
  108.     function ICSOInitShared (globals: globalsHandle): ComponentResult;
  109.     begin
  110.         ICSOInitShared := noErr;
  111.     end; (* ICSOInitShared *)
  112.  
  113.     function ICSOCleanShared (globals: globalsHandle): ComponentResult;
  114.     begin
  115.         ICSOCleanShared := noErr;
  116.     end; (* ICSOCleanShared *)
  117.  
  118.     function ICSOInitGlobals (globals: globalsHandle): ComponentResult;
  119.     begin
  120.         ICSOInitGlobals := noErr;
  121.     end; (* ICSOInitGlobals *)
  122.  
  123.     function ICSOCleanGlobals (globals: globalsHandle): ComponentResult;
  124.     begin
  125.         ICSOCleanGlobals := noErr;
  126.     end; (* ICSOCleanGlobals *)
  127.  
  128.     function ICSOCanDo (globals: globalsHandle; selector: integer): ComponentResult;
  129.     begin
  130.         ICSOCanDo := delegateThisCallErr;
  131.     end; (* ICSOCanDo *)
  132.  
  133.     function RSCGetPref (globals: globalsHandle; key: Str255; var attr: ICAttr; buf: Ptr; var size: longint): ICError;
  134.         var
  135.             err: ICError;
  136.     begin
  137.         err := ICCGetPref(globals^^.delegate, key, attr, buf, size);
  138.         bset(attr, ICattr_locked_bit);
  139.         RSCGetPref := err;
  140.     end; (* RSCGetPref *)
  141.  
  142.     function RSCSetPref (globals: globalsHandle; key: Str255; var attr: ICAttr; buf: Ptr; var size: longint): ICError;
  143.     begin
  144.         RSCSetPref := icPermErr;
  145.     end; (* RSCSetPref *)
  146.  
  147.     function ICSOWhatToOverride (globals: globalsHandle; selector: integer): ProcPtr;
  148.         var
  149.             proc: ProcPtr;
  150.     begin
  151.         proc := nil;
  152.         case selector of
  153.             kICCGetPref: 
  154.                 proc := @RSCGetPref;
  155.             kICCSetPref: 
  156.                 proc := @RSCSetPref;
  157.             otherwise
  158.                 ;
  159.         end; (* case *)
  160.         ICSOWhatToOverride := proc;
  161.     end; (* ICSOWhatToOverride *)
  162.  
  163. end. (* ICSpecificOverride *)
  164.